package com.example.test.core.service;

import com.example.test.core.entity.User;
import com.example.test.core.mapper.master.MasterUserMapper;
import com.example.test.core.mapper.second.SecondUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.logging.Logger;

@Service
@Transactional
public class UserService {

    private static final Logger log = Logger.getLogger("UserService");
    /**
     * 用户信息查询接口类
     */
    @Autowired
    private MasterUserMapper masterUserMapper;
    @Autowired
    private SecondUserMapper secondUserMapper;

    public List<User> getName(String loginName) {
        log.info("根据域账号获取用户姓名" + loginName);
        List<User> users = masterUserMapper.getName(loginName);
        return users;
    }

    public List<User> getNotes() {
        List<User> users = secondUserMapper.getNotes();
        return users;
    }

    public boolean updateUser(String name, String no) {
        masterUserMapper.updateUser("恍恍惚惚", no);
        log.info("更新了");
        int flag = masterUserMapper.updateUser(name, no);
        if (flag > 0) {
            throw new RuntimeException("失败了");
        }
        return true;
    }

    public List<String> queryUsers() {
        List<String> list = masterUserMapper.queryUsers();
        return list;
    }

    public int queryCountByNo(String no) {
        int count = masterUserMapper.queryCountByNo(no);
        return count;
    }
}